package org.ds.blog.model;

import lombok.AllArgsConstructor;
import lombok.Data;

@Data
@AllArgsConstructor
public class Response {
    private String code;
    private String message;
    private Object data;

    private Response(){

    }

    public static Response ok() {
        Response response = new Response();
        response.setCode(CustomCode.SUCCESS.getCode());
        response.setMessage(CustomCode.SUCCESS.getMessage());
        return response;
    }
    public static Response fail() {
        Response response = new Response();
        response.setCode(CustomCode.FAILED.getCode());
        response.setMessage(CustomCode.FAILED.getMessage());
        return response;
    }
    public Response code(String code) {
        this.setCode(code);
        return this;
    }
    public Response message(String message) {
        this.setMessage(message);
        return this;
    }

    public Response data(Object data) {
        this.setData(data);
        return this;
    }
}
